$(function () {
    const urlHotpic = '/index/hotpic';
    const urlLatest = '/index/latest';
    const urlAttention = '/index/attention';
    const urlLatestComment = '/index/latest_comment';
    const urlRank = '/index/rank';

    // 热点图
    ajax('get', urlHotpic).then(res => {
        console.log(res)
        const ele = template('foucsImg', {
            data: res.data
        });
        $('.focus_list').html(ele);
        $('.focus_list li').eq(0).addClass('first');
    })

    // 咨询
    ajax('get', urlLatest).then(res => {
        console.log(res.data);
        const ele = template('commonNews', {
            data: res.data
        });
        $('.common_news').html(ele);
    })

    // 聚焦关注
    ajax('get', urlAttention).then(res => {
        console.log(res)
        const ele = template('attention', {
            data: res.data
        });
        $('.guanzhu_list').html(ele);
        console.log(ele);
    })

    // 最新评论
    ajax('get', urlLatestComment).then(res => {
        const ele = template('commentList', {
            data: res.data
        });
        $('.comment_list').html(ele);
    })

    // 一周热门排行
    ajax('get', urlRank).then(res => {
        const ele = template('hotrankList', {
            data: res.data
        })
        $('.hotrank_list').html(ele);

        // 排行样式
        $('.hotrank_list li').eq(0).find('span').addClass('first');
        $('.hotrank_list li').eq(1).find('span').addClass('second');
        $('.hotrank_list li').eq(2).find('span').addClass('third');
    })
})